﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace Pdm.Commons
{
    public class PdmOptimization : Optimization
    {
        public List<SpecificationInstance> urmWeights { get; set; }
        public List<SpecificationInstance> directions { get; set; }
        public List<SpecificationInstance> pdmWeights { get; set; }
        public double alpha { get; set; }


        public PdmOptimization(DmuList dmuList, int objectiveDmu)
            : base(dmuList, objectiveDmu)
        {
            this.urmWeights = new List<SpecificationInstance>();
            this.directions = new List<SpecificationInstance>();
            this.pdmWeights = new List<SpecificationInstance>();
        }
        public void setOptimizationDirections(Optimization solvedDea)
        {
            this.deaWeights = solvedDea.deaWeights;

            int firstOut = solvedDea.dmuList.getIDofFirstOutputCoeffiecient();
            int i = 0;
            foreach (SpecificationInstance deaWeightSpec in solvedDea.deaWeights)
            {
                if (deaWeightSpec.spec.type == Type.Input)
                {
                    directions.Add(new SpecificationInstance(dmuList.coefficients[i], 0));
                    Debug.WriteLine(0);
                }
                else
                {
                    if (deaWeightSpec.value / solvedDea.deaWeights[firstOut].value >
                       urmWeights[i].value / urmWeights[firstOut].value)
                    {
                        directions.Add(new SpecificationInstance(dmuList.coefficients[i], 1));
                        Debug.WriteLine(1);
                    }
                    else
                    {
                        directions.Add(new SpecificationInstance(dmuList.coefficients[i], -1));
                        Debug.WriteLine(-1);
                    }
                }
                i++;
            }
        }
        public static void calculateOptimizationDirections()
        {
            //DEA anlegen, durchführen und dirs berechnen

        }
    }
}
